#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;
    string s1, s2;
    cin >> n;
    while (n--) {
        cin >> s1 >> s2;
        if (s1.size() != s2.size()) {
            cout << "false" << endl;
            continue;
        } else {
            int tot = 0;
            for (int i = 0; i < s1.size(); i++)
                tot += s1[i] - s2[i];
            if (tot == (s1[0] - s2[0]) * s1.size())
                cout << "true" << endl;
            else
                cout << "false" << endl;
        }
    }
}